﻿<%@ Page Title="" Language="C#" MasterPageFile="~/LTR/MlyLtrMaster.Master" AutoEventWireup="true" CodeBehind="Alerts.aspx.cs" Inherits="MLY.LTR.Alerts" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>

<asp:Content ID="Content1" ContentPlaceHolderID="titleHolder" runat="server">
    <style type="text/css">
        .TitleStyle
        {
            font-family:Arial Sans-Serif David;
            font-size:14px;
            font-weight:bold;
            color:Black;
            background-color:#86C2FF;            
        }
        
        .InnerTextStyle
        {
            font-family:Arial Sans-Serif David;
            font-size:12px;
            color:Black;
            text-decoration:none;
        }
        
        .InnerTextStyle:hover
        {
            text-decoration:underline;    
        }
        
        .BigInnerTextStyle
        {
            font-family:Arial Sans-Serif David;
            font-size:14px;
            color:Black;
            text-decoration:none;
        }
        
        .BigInnerTextStyle:hover
        {
            text-decoration:underline;    
        }
    </style>
    <script language="javascript" type="text/javascript">
        
        window.onload = function() {
            $("#my_alertsmenuitem").addClass('active');
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div id="content" class="SC_Align">
        <br />
        <h4><asp:Label ID="MessageLabel" runat="server" Text=""></asp:Label></h4>  
        <br /><br />
        <asp:Button ID="CreateAlertButton" CssClass="SC_Button" PostBackUrl="~/LTR/CreateAlert.aspx"
         Text="<%$ Dict:Alerts.CreateAlert %>" runat="server"></asp:Button>
        <asp:Button ID="AllAlertsButton" CssClass="SC_Button" PostBackUrl="~/LTR/MyAlerts.aspx"
         Text="My alerts" runat="server"></asp:Button>         
        <br />
        <br />
        <asp:Panel ID="AlertCreatedPanel" runat="server" Visible="false" >
            <div class="democlass" style="width:250px;">
                Here is the alert that you have created. You can edit its main parameters here.
            </div>
        </asp:Panel>
        <h4><asp:Literal ID="AllDefinedAlertsTitle" runat="server" Text="<%$ Dict:Alerts.AllDefinedAlerts %>"></asp:Literal></h4>        
        <asp:GridView ID="AlertsGridview" runat="server" DataSourceID="AlertsListDataSource" AllowPaging="false"
         AutoGenerateColumns="false" DataKeyNames="AlertId" CellPadding="4"  >
         <PagerSettings Mode="NumericFirstLast" LastPageImageUrl="~/Images/Icons/Next.png"
             PreviousPageImageUrl="~/Images/Icons/Prev.png" NextPageImageUrl="~/Images/Icons/Next.png"
             PageButtonCount="7" Position="Bottom" FirstPageImageUrl="~/Images/Icons/Prev.png"  />
            <PagerStyle CssClass="pagination" HorizontalAlign="Left" />
            
            <HeaderStyle CssClass="SC_grid_header"  />
            <RowStyle CssClass="SC_grid_cell"  />
         <Columns>
            <asp:TemplateField HeaderText="<%$ Dict:Alerts.AlertName %>">
                <ItemTemplate>
                    <asp:Label ID="AlertNameLabel" runat="server" Text='<%# Eval("AlertName") %>' ></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="AlertTextBox" runat="server" Text='<%# Bind("AlertName") %>' Width="100" TextMode="SingleLine" MaxLenth="256"></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ Dict:Alerts.SendMail %>">
                <ItemTemplate>
                    <asp:Image ID="SendEmailImage" runat="server" ImageUrl="~/Images/Approve.gif" Visible='<%# Eval("ActionEmail") %>' />
                    <asp:Image ID="NoSendEmailImage" runat="server" ImageUrl="~/Images/Cancel.gif" Visible='<%# !(bool)Eval("ActionEmail") %>' />
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:CheckBox ID="SendEmailCheckBox" runat="server" Checked='<%# Bind("ActionEmail") %>' />
                    <ajax:ToggleButtonExtender ID="SendEmailCheckBoxCBE" runat="server" CheckedImageUrl="~/Images/Icons/CheckBoxChecked.png"
                         UncheckedImageUrl="~/Images/Icons/CheckBoxUnChecked.png" CheckedImageAlternateText="Checked" UncheckedImageAlternateText="Unchecked"
                          TargetControlID="SendEmailCheckBox" ImageWidth="21" ImageHeight="20" ></ajax:ToggleButtonExtender>
                </EditItemTemplate>            
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ Dict:Alerts.MarkRow %>">
                <ItemTemplate>
                    <asp:Image ID="MarkRowImage" runat="server" ImageUrl="~/Images/Approve.gif" Visible='<%# Eval("ActionMarkRow") %>' />
                    <asp:Image ID="NoMarkRowImage" runat="server" ImageUrl="~/Images/Cancel.gif" Visible='<%# !(bool)Eval("ActionMarkRow") %>' />
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:CheckBox ID="MarkRowCheckBox" runat="server" Checked='<%# Bind("ActionMarkRow") %>' />
                    <ajax:ToggleButtonExtender ID="MarkRowCheckBoxCBE" runat="server" CheckedImageUrl="~/Images/Icons/CheckBoxChecked.png"
                         UncheckedImageUrl="~/Images/Icons/CheckBoxUnChecked.png" CheckedImageAlternateText="Checked" UncheckedImageAlternateText="Unchecked"
                          TargetControlID="MarkRowCheckBox" ImageWidth="21" ImageHeight="20" ></ajax:ToggleButtonExtender>
                </EditItemTemplate>   
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ Dict:Alerts.NewEntry %>">
                <ItemTemplate>
                    <asp:Image ID="NewEventImage" runat="server" ImageUrl="~/Images/Approve.gif" Visible='<%# Eval("EventNewRow") %>' />
                    <asp:Image ID="NoNewEventImage" runat="server" ImageUrl="~/Images/Cancel.gif" Visible='<%# !(bool)Eval("EventNewRow") %>' />
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:CheckBox ID="NewEventCheckBox" runat="server" Checked='<%# Bind("EventNewRow") %>' />
                    <ajax:ToggleButtonExtender ID="NewEventCheckBoxCBE" runat="server" CheckedImageUrl="~/Images/Icons/CheckBoxChecked.png"
                         UncheckedImageUrl="~/Images/Icons/CheckBoxUnChecked.png" CheckedImageAlternateText="Checked" UncheckedImageAlternateText="Unchecked"
                          TargetControlID="NewEventCheckBox" ImageWidth="21" ImageHeight="20" ></ajax:ToggleButtonExtender>
                </EditItemTemplate>   
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Is critical">
                <ItemTemplate>
                    <asp:Image ID="IsCriticalImage" runat="server" AlternateText="critical"
                     ImageUrl='<%# (bool)Eval("IsCritical") ? "~/Images/Approve.gif" : "~/Images/Cancel.gif" %>' />
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:CheckBox ID="IsCriticalCB" runat="server" Checked='<%# Bind("IsCritical") %>' />
                    <ajax:ToggleButtonExtender ID="IsCriticalCBE" runat="server" CheckedImageUrl="~/Images/Icons/CheckBoxChecked.png"
                         UncheckedImageUrl="~/Images/Icons/CheckBoxUnChecked.png" CheckedImageAlternateText="Checked" UncheckedImageAlternateText="Unchecked"
                          TargetControlID="IsCriticalCB" ImageWidth="21" ImageHeight="20" ></ajax:ToggleButtonExtender>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:HiddenField ID="AlertIdxHiddenField" runat="server" Value='<%# Eval("AlertId") %>'/>
                    <%--<asp:LinkButton ID="EditLinkButton" runat="server" CommandName="Edit" Text="Edit"></asp:LinkButton>
                    &nbsp;--%>
                    <asp:HyperLink ID="AlertDetailsLink" runat="server" Text="<%$ Dict:MainMenu.Details %>"
                     NavigateUrl='<%# "CreateAlert.aspx?AlertId=" + Eval("AlertId") %>' ></asp:HyperLink>
                     &nbsp;
                    
                    <asp:ImageButton ID="DeleteLinkButton" runat="server" CommandName="Delete" ToolTip="<%$ Dict:ClientsGrid.Delete %>"
                    message="<%# ConfirmDictMessage() %>" OnClientClick="return confirm(this.getAttribute('message'))" ImageUrl="~/Images/Cancel.gif" />
                    
                </ItemTemplate> 
                <EditItemTemplate>
                    <asp:HiddenField ID="AlertIdxHiddenField" runat="server" Value='<%# Bind("AlertId") %>'/>
                    <asp:LinkButton ID="UpdateLinkButton" runat="server" CommandName="Update" CssClass="InnerTextStyle"
                     Text="<%$ Dict:adminDefault.lblUpdate %>"></asp:LinkButton>
                    &nbsp;
                    <asp:LinkButton ID="CancelLinkButton" runat="server" CommandName="Cancel" CssClass="InnerTextStyle"
                     Text="<%$ Dict:EditMessage.Cancel %>"></asp:LinkButton>
                    &nbsp;
                    <asp:HyperLink ID="AlertDetailsLink" runat="server" Text="<%$ Dict:MainMenu.Details %>"
                     NavigateUrl='<%# "CreateAlert.aspx?AlertId=" + Eval("AlertId") %>' ></asp:HyperLink>
                </EditItemTemplate>
            </asp:TemplateField>
         </Columns>
         <EmptyDataTemplate>
             <asp:Literal ID="NoAlertsLiteral" runat="server" Text="<%$ Dict:Alerts.NoDefinedAlerts %>"></asp:Literal>
         </EmptyDataTemplate>
        </asp:GridView>
        
        <asp:SqlDataSource ID="AlertsListDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:MLYConnectionString %>"
        SelectCommand="AlertGetUserAlerts" SelectCommandType="StoredProcedure"        
        UpdateCommand="AlertUpdateShort" UpdateCommandType="StoredProcedure"
        DeleteCommand="AlertDelete" DeleteCommandType="StoredProcedure">
            <SelectParameters>
                <asp:SessionParameter Name="UserId" DbType="Int32" SessionField="UserId" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Type="Int32" Name="AlertId" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Type="Int32" Name="AlertId" />
                <asp:Parameter Type="String" Name="AlertName" />
                <asp:Parameter Type="Boolean" Name="ActionEmail" />
                <asp:Parameter Type="Boolean" Name="ActionMarkRow" />
                <asp:Parameter Type="Boolean" Name="EventNewRow" />                
                <asp:Parameter Type="Boolean" Name="IsCritical" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>
</asp:Content>
